<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>01-document获取元素</title>
    <SCRIPT>
        // 根据id获取标签
        window.onload = function () {
            var elementById = document.getElementById("box1");
            console.log(elementById);
            console.log(typeof elementById);

            // 根据类名来获取标签 两个以上的值获取的是数组
            var elementsByClassName = document.getElementsByClassName("box2");
            for (let i = 0; i < elementsByClassName.length; i++) {
                console.log(elementsByClassName[i]);
            }
            // 根据标签来获取
            var elementsByTagName = document.getElementsByTagName("p");
            for (let i = 0; i < elementsByTagName.length; i++) {
                console.log(elementsByTagName[i]);
            }
        }
    </SCRIPT>
</head>
<body>
    <div id="box1">
      我是盒子1
    </div>
    <div class="box2">
        我是盒子2
    </div>
    <div class="box2">
        我是盒子3
    </div>
    <p>我是p标签1</p>
    <p>我是p标签2</p>
    <p>我是p标签3</p>
</body>
</html>